home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / TOOLPAS2 / IXDIR.PAS < prev    next >
Pascal/Delphi Source File  |  1990-05-17  |  2KB  |  84 lines

  1.  
  2. {$m 10000,0,0}
  3.  
  4. uses dos,tools,mdosio,bindex,openshare,qread;
  5.  
  6. var
  7.    ixname:  bindex_handle;
  8.    ixdate:  bindex_handle;
  9.    fd:      text;
  10.    fid:     longint;
  11.    fpos:    longint;
  12.    line:    string;
  13.  
  14. begin
  15.    if paramcount <> 3 then
  16.    begin
  17.       writeln('usage:  ixdir DIRFILE CONF# DIR#');
  18.       writeln('example: ixdir L:\PCB\GEN\DIR1 0 1');
  19.       halt(1);
  20.    end;
  21.  
  22.    fid := atoi(paramstr(2))*256 + atoi(paramstr(3));
  23.  
  24.    if not dos_exists(paramstr(1)) then
  25.    begin
  26.       writeln('Can''t open dirfile');
  27.       halt;
  28.    end;
  29.  
  30.    assign(fd,paramstr(1));
  31.    reset(fd);
  32.  
  33.    if not dos_exists('NAMES.IX') then
  34.    begin
  35.       ixname.hdr.keysize := 12;
  36.       ixname.hdr.keytype := StringKey;
  37.       CreateIndex(ixname,'NAMES.IX');
  38.    end;
  39.  
  40.    if not dos_exists('DATES.IX') then
  41.    begin
  42.       ixdate.hdr.keysize := 6;
  43.       ixdate.hdr.keytype := DateKey;
  44.       CreateIndex(ixdate,'DATES.IX');
  45.    end;
  46.  
  47.    OpenIndex(ixname,'NAMES.IX');
  48.    OpenIndex(ixdate,'DATES.IX');
  49.  
  50.    while not eof(fd) do
  51.    begin
  52.       qReadLn(fd,line,255);
  53.       {PROBB10.ZIP     46620  12-24-89  Official list }
  54.       {123456789012345678901234567890123456}
  55.       {         1         2         3      }
  56.       if (length(line) > 33) and (line[26] = '-') and (line[23] = ' ') then
  57.       with TextRec(fd) do
  58.       begin
  59.          dos_lseek(Handle,0,seek_cur);
  60.          fpos := dos_tell-BufEnd+BufPos-length(line)-2;
  61.  
  62.          ixname.rec.key := copy(line,1,12);
  63.          ixname.rec.fid := fid;
  64.          ixname.rec.fpos := fpos;
  65.          write(ixname.rec.key:12,' ');
  66.          AddKey(ixname);
  67.  
  68.          ixdate.rec.key := line[30]+line[31] +
  69.                            line[24]+line[25] +
  70.                            line[27]+line[28];
  71.          ixdate.rec.fid := fid;
  72.          ixdate.rec.fpos := fpos;
  73.          writeln(ixdate.rec.key);
  74.          AddKey(ixdate);
  75.       end;
  76.  
  77.    end;
  78.  
  79.    CloseIndex(ixdate);
  80.    CloseIndex(ixname);
  81.    close(fd);
  82. end.
  83.  
  84.